<?php //pack11class

class NewPropertyPopup extends Module {

    public $width="400px";
    public $traceEnabled=true;
    public $cancel="Cancel";
    public $question="Undefined";
    public $submit="Submit";
    public $buttons="";

    public function setup() {
        $this->question=LabelManager::getLabel("new_property_label");
        $this->setID("NewPropertyPopup");
        $this->setClass("popup");
        $spacer=new Spacer;
        $spacer->addStyle("height","4px");
        $this->addChild($spacer);

        $languages=LanguagesManager::getLanguages();
        foreach($languages as $language) {
            $field=new TextInput();
            $field->label=$language->label;
            $field->id="np_".$language->system;
            $field->setClass("LangInput");
            $field->property_name=str_replace("`","",$language->field);
            $this->addChild($field);
        }

        $types=TypeManager::getType();
        $typesContainer = new SimpleModule;
        $typesContainer1 = new SimpleModule;
        $typesContainer2 = new SimpleModule;
        $maxc=ceil(count($types)/2);
        $pcounter=1;

        foreach($types as $type) {
            $item=new RadioInput();
            $item->label=$type->label;
            $item->value=$type->id;
            if($type->id==1) $item->checked=RadioInput::CHECKED;
            $item->setClass("TypeItem");
            $item->property_name="type";
            if($pcounter>$maxc) {
                $typesContainer2->addChild($item);
            } else {
                $typesContainer1->addChild($item);
            }
            $pcounter++;
        }

        $typesContainer->setClass("TypesContainer");
        $typesContainer1->setClass("TypesContainer1");
        $typesContainer2->setClass("TypesContainer2");
        $typesContainer->addChild($typesContainer1);
        if($pcounter>$maxc-1)$typesContainer->addChild($typesContainer2);
        $this->addChild($typesContainer);

        // GROUP >>
        $select=new SelectInput;

        $options=GroupsManager::getGroup();
        $selDone=false;

        $option=new SelectOption;
        $option->selected=SelectOption::SELECTED;
        $option->label=LabelManager::getLabel("not_group_label");
        $option->value=0;
        $select->addChild($option);

        foreach($options as $value) {
            $option=new SelectOption;
            $option->label=$value->label;
            $option->value=$value->id;
            $select->addChild($option);
        }

        $select->label=LabelManager::getLabel("groups_label");
        $select->property_name="group";
        $select->setID("NewPropertyGroup");
        $select->setClass("GroupSelect");
        $select->lamp_class="hidden";
        $this->addChild($select);

        // << GROUP

        // >> SYSTEM

         $field=new TextInput();
         $field->label=LabelManager::getLabel("system_name_label");
         $field->id="system_name";
         $field->setClass("LangInput");
         $field->property_name="system";
         $this->addChild($field);

        // << SYSTEM

        $cancel=new FormButton;
        $cancel->value=LabelManager::getLabel("button_cancel");
        $cancel->type=FormButton::TYPE_BUTTON;
        $cancel->setID("NewPropertyCancel");
        $this->buttons.=Template::html($cancel);

        $save=new FormButton;
        $save->value=LabelManager::getLabel("button_save");
        $save->type=FormButton::TYPE_BUTTON;
        $save->setID("NewPropertySubmit");
        $this->buttons.=Template::html($save);

    }

}
?>
